namespace _2._18._2015_MoviesInClass.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class addAuditObjectToActors : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Movies", "UserId", "dbo.AspNetUsers");
            DropIndex("dbo.Movies", new[] { "UserId" });
            AddColumn("dbo.Actors", "DateCreated", c => c.DateTime());
            AddColumn("dbo.Actors", "CreatedById", c => c.String(maxLength: 128));
            AddColumn("dbo.Actors", "DateUpdated", c => c.DateTime());
            AddColumn("dbo.Actors", "UpdatedById", c => c.String(maxLength: 128));
            AddColumn("dbo.Actors", "IsDeleted", c => c.Boolean());
            AlterColumn("dbo.Movies", "UserId", c => c.String(nullable: false, maxLength: 128));
            CreateIndex("dbo.Actors", "CreatedById");
            CreateIndex("dbo.Actors", "UpdatedById");
            CreateIndex("dbo.Movies", "UserId");
            AddForeignKey("dbo.Actors", "CreatedById", "dbo.AspNetUsers", "Id");
            AddForeignKey("dbo.Actors", "UpdatedById", "dbo.AspNetUsers", "Id");
            AddForeignKey("dbo.Movies", "UserId", "dbo.AspNetUsers", "Id", cascadeDelete: true);
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Movies", "UserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.Actors", "UpdatedById", "dbo.AspNetUsers");
            DropForeignKey("dbo.Actors", "CreatedById", "dbo.AspNetUsers");
            DropIndex("dbo.Movies", new[] { "UserId" });
            DropIndex("dbo.Actors", new[] { "UpdatedById" });
            DropIndex("dbo.Actors", new[] { "CreatedById" });
            AlterColumn("dbo.Movies", "UserId", c => c.String(maxLength: 128));
            DropColumn("dbo.Actors", "IsDeleted");
            DropColumn("dbo.Actors", "UpdatedById");
            DropColumn("dbo.Actors", "DateUpdated");
            DropColumn("dbo.Actors", "CreatedById");
            DropColumn("dbo.Actors", "DateCreated");
            CreateIndex("dbo.Movies", "UserId");
            AddForeignKey("dbo.Movies", "UserId", "dbo.AspNetUsers", "Id");
        }
    }
}
